<!DOCTYPE html>
<html lang="en">

<head>
    <title>Example</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        table {
            border: solid thin black;
            border-collapse: collapse;
            margin: 10px;
        }
        
        td {
            padding: 4px 5px;
        }
    </style>
</head>

<body>
    <table border="1">
        <thead>
            <tr>
                <th>Multiply</th>
                <th>Result</th>
            </tr>
        </thead>
        <tbody id="fruitsBody">
            <tr>
                <td class="sum">1 * 1</td>
                <td class="result">1</td>
            </tr>
        </tbody>
    </table>
    <button id="add">Add Row</button>
    <script>
        var tableBody = document.getElementById('fruitsBody');

        document.getElementById('add').onclick = function () {
            var count = tableBody.getElementsByTagName('tr').length + 1;
            var newElem = tableBody.getElementsByTagName('tr')[0].cloneNode(true);
            newElem.getElementsByClassName("sum")[0].firstChild.data = count + " * " + count;
            newElem.getElementsByClassName("result")[0].firstChild.data = count * count;
            tableBody.appendChild(newElem);
        };
    </script>
</body>

</html>